//
//  OrderDetailTransRecVC.m
//  WorkNest
//
//  Created by giantumbrella on 15/7/28.
//  Copyright (c) 2015年 nest. All rights reserved.
//

#import "OrderDetailTransRecVC.h"
#import "TransactionRecordsModel.h"

@interface OrderDetailTransRecVC ()

@property (nonatomic,strong) UIView *topBgPriceView;
@property (nonatomic,strong) UIView *middelBgDetailView;
@property (nonatomic,strong) UIView *buttomBgTimeView;

@property (nonatomic,strong) UIImageView *imageULR;
@property (nonatomic,strong) UILabel *labelOrderNum;
@property (nonatomic,strong) UILabel *labelDetail;

@end

@implementation OrderDetailTransRecVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = UIColorWithRGBA(242, 242, 242, 1);
    self.title = @"订单详情";
    
    //创建头部信息
    [self createTopView];
    
    //创建中间部分界面
    [self createMiddleSubviews];
    
    //创建底部视图
    [self createButtonSubview];
}

#pragma mark 创建头部信息
- (void)createTopView
{
    self.topBgPriceView = [[UIView alloc] initWithFrame:CGRectMake(0,0, SCREEN_WIDTH, 50)];
    [self.view addSubview:self.topBgPriceView];
    self.topBgPriceView.backgroundColor = [UIColor whiteColor];
    
    UILabel *labelTextPlayfot = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH*0.5, self.topBgPriceView.frame.size.height)];
    [self.topBgPriceView addSubview:labelTextPlayfot];
    labelTextPlayfot.text = @"平台产品下单";
    labelTextPlayfot.textColor = UIColorWithRGBA(138, 138, 138, 1);
    labelTextPlayfot.font = [UIFont systemFontOfSize:15];
    
    UILabel *labelPrice = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH*0.5, 0, SCREEN_WIDTH*0.5-10, self.topBgPriceView.frame.size.height)];
    [self.topBgPriceView addSubview:labelPrice];
    labelPrice.textAlignment = NSTextAlignmentRight;
    labelPrice.text = self.pathTransactionRecordsModel.transrecPrice;
    
    //横线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, self.topBgPriceView.frame.size.height-1, SCREEN_WIDTH, 1)];
    [self.topBgPriceView addSubview:lineView];
    lineView.backgroundColor = UIColorWithRGBA(227, 227, 227, 1);

}

#pragma mark 创建中间部分界面
- (void)createMiddleSubviews
{
    
    self.middelBgDetailView = [[UIView alloc] initWithFrame:CGRectMake(0,self.topBgPriceView.frame.size.height+10, SCREEN_WIDTH, 115)];
    [self.view addSubview:self.middelBgDetailView];
    self.middelBgDetailView.backgroundColor = [UIColor whiteColor];
    
    //横线
    UIView *lineViewTop = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
    [self.middelBgDetailView addSubview:lineViewTop];
    lineViewTop.backgroundColor = UIColorWithRGBA(227, 227, 227, 1);
    
    //产品图片
    self.imageULR = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 105, 95)];
    [self.middelBgDetailView addSubview:self.imageULR];
    self.middelBgDetailView.layer.cornerRadius = 3;
    self.middelBgDetailView.clipsToBounds = YES;
    self.imageULR.backgroundColor = [UIColor greenColor];
    
    //详述
    self.labelDetail = [[UILabel alloc] initWithFrame:CGRectMake(self.imageULR.frame.size.width + 20, 10, SCREEN_WIDTH - 135, 55)];
    [self.middelBgDetailView addSubview:self.labelDetail];
    self.labelDetail.text = self.pathTransactionRecordsModel.transrecTitle;
    self.labelDetail.textColor = UIColorWithRGBA(130, 130, 130, 1);
    self.labelDetail.numberOfLines = 0;
    self.labelDetail.font = [UIFont systemFontOfSize:14];
//    [self.labelDetail sizeToFit];
    
    //产品编号
    UILabel *labelProductCode = [[UILabel alloc] initWithFrame:CGRectMake(self.labelDetail.frame.origin.x,70, self.labelDetail.frame.size.width, 16)];
    [self.middelBgDetailView addSubview:labelProductCode];
    labelProductCode.text = [NSString stringWithFormat:@"产品编号:%@",self.pathTransactionRecordsModel.transrecCode];
     labelProductCode.textColor = UIColorWithRGBA(130, 130, 130, 1);
    labelProductCode.font = [UIFont systemFontOfSize:14];

    
    //订单号
    self.labelOrderNum = [[UILabel alloc] initWithFrame:CGRectMake(self.labelDetail.frame.origin.x,labelProductCode.frame.origin.y+labelProductCode.frame.size.height + 2, self.labelDetail.frame.size.width, 16)];
    [self.middelBgDetailView addSubview:self.labelOrderNum];
    self.labelOrderNum.textColor = UIColorWithRGBA(130, 130, 130, 1);
    self.labelOrderNum.text = [NSString stringWithFormat:@"订单号:%@",self.pathTransactionRecordsModel.transrecOrderNum];
    self.labelOrderNum.font = [UIFont systemFontOfSize:14];

    
       //横线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 114, SCREEN_WIDTH, 1)];
    [self.middelBgDetailView addSubview:lineView];
    lineView.backgroundColor = UIColorWithRGBA(227, 227, 227, 1);
    
}

#pragma mark 创建底部视图
- (void)createButtonSubview
{
    self.buttomBgTimeView = [[UIView alloc] initWithFrame:CGRectMake(0,self.middelBgDetailView.frame.size.height+10+self.middelBgDetailView.frame.origin.y, SCREEN_WIDTH, 100)];
    [self.view addSubview:self.buttomBgTimeView];
    self.buttomBgTimeView.backgroundColor = [UIColor whiteColor];
    //横线
    UIView *lineViewTop = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 1)];
    [self.buttomBgTimeView addSubview:lineViewTop];
    lineViewTop.backgroundColor = UIColorWithRGBA(227, 227, 227, 1);
    
    NSArray *titleArray;
    titleArray = @[@"创建时间：",@"交易号：",@"付款方式："];
    
    for (int i=0; i<3; i++) {
        UILabel *labelTile = [[UILabel alloc] initWithFrame:CGRectMake(0, 5+33*i, SCREEN_WIDTH*0.25, 33)] ;
        [self.buttomBgTimeView addSubview:labelTile];
        labelTile.text = titleArray[i];
        labelTile.font = [UIFont systemFontOfSize:14];
        labelTile.textColor = UIColorWithRGBA(154, 154, 154, 1);
        labelTile.textAlignment = NSTextAlignmentRight;
    }

    NSMutableArray *strArray = [[NSMutableArray alloc] init];
    [strArray addObject:self.pathTransactionRecordsModel.transrecCreateTime];
    [strArray addObject:self.pathTransactionRecordsModel.transrectransNum];
    [strArray addObject:self.pathTransactionRecordsModel.transrecPayType];
    
    //创建时间 交易号 付款方式
    for (int i=0; i<3; i++) {
        UILabel *labelAll = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH*0.25, 5+33*i, SCREEN_WIDTH*0.6, 33)];
        [self.buttomBgTimeView addSubview:labelAll];
        labelAll.font = [UIFont systemFontOfSize:14];
        labelAll.text = strArray[i];
    }
    //横线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 99, SCREEN_WIDTH, 1)];
    [self.buttomBgTimeView addSubview:lineView];
    lineView.backgroundColor = UIColorWithRGBA(227, 227, 227, 1);
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
